package main

import (
	"executeserver/src/worker"
	"fmt"
	"regexp"
)

var funcMaps = map[string]interface{}{
	"handlePostedData": worker.HandleReceiveTask,
}

func main() {
	list := make(map[string]string)
	list["username"] = "admin"
	list["password"] = "admin1"
	var i = -1
	text := "select * from admin_users where (username=${username} or password = ${password})"
	whereReg := regexp.MustCompile(`where\s+\((.*?)\)`)
	fmt.Println(whereReg.FindAllString(text, -1))
	fmt.Println(whereReg.FindAllStringSubmatch(text, -1))
	reg := regexp.MustCompile(`\$\{(.*?)\}`)

	fmt.Println(reg.FindAllString(text, -1))
	fmt.Println(reg.ReplaceAllString(text, "；"))
	fmt.Println(reg.FindAllStringSubmatch(text, -1))
	fmt.Println(reg.MatchString(text))
	fmt.Println(reg.SubexpNames())
	fmt.Println(reg.ReplaceAllStringFunc(text, func(s string) string {
		v := s[2 : len(s)-1]
		fmt.Println(v)

		i++
		// return list[i]
		return list[v]
	}))
	fmt.Println(text)
}
